package com.tzeng.hist.fragment;

import java.util.List;
import java.util.Map;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.tzeng.adapter.NewsAdapter;
import com.tzeng.data.DataService;
import com.tzeng.hist.R;
import com.tzeng.hist.activity.NewsDetailActivity;

public class TabFragment1 extends Fragment implements OnItemClickListener{ 
	public List<Map<String, Object>> listCFNews;
	public ListView mCFNewsListView;
	public NewsAdapter cfNewsAdapter;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.fragement_tab1, container, false);
	}

	@Override
	public void onActivityCreated(@Nullable Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		listCFNews = DataService.getTestData();
		mCFNewsListView = (ListView) getActivity().findViewById(R.id.listview);
		mCFNewsListView.setOnItemClickListener(this);
		cfNewsAdapter = new NewsAdapter(getActivity(), listCFNews);
		mCFNewsListView.setAdapter(cfNewsAdapter);
	}
	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		// TODO Auto-generated method stub
		Intent intent = new Intent(getActivity(),NewsDetailActivity.class);
		startActivity(intent);
	}
}
